<?php

namespace App\Models;

use App\User;

class Hr extends User {

    public $table = 'users';

    public function scopeOfAll($query)
    {
        $query->select('users.id', 'users.name', 'users.last_logined_at','users.mobile', 'users.updated_at', 'users.email')
            ->leftJoin('role_user', 'users.id', '=', 'user_id')
            ->leftJoin('roles', 'roles.id', '=', 'role_user.role_id')
            ->where('roles.name', config('setting.hrGroup'));

        return $query;
    }

    public function scopeOfSearch($query, $fieldValue)
    {
        return $query->where('users.name', 'like', "%$fieldValue%")
            ->orWhere('email', $fieldValue)
            ->orWhere('mobile', $fieldValue);
    }
}
